package com.mingqi.enetconnected.net.request;

import android.content.Context;

import com.google.gson.reflect.TypeToken;

import java.lang.reflect.Type;
import java.util.HashMap;

/**
 * 16101 PrivilegeRemoteService
 * 共2个，已完成
 */
public class UserPrivilegeRemoteOption {
    /**
     * 查询用户权限
     */
    public final static String SEARCH_USER_PRIVILEGE = "/uum/user/privileges/";

    /**
     * 查询用户所有权限
     * @param cxt
     * @param type  权限类型的编码,多个用英文逗号分割
     */
    public static String searchUserPrivileges(Context cxt, String type) throws Exception {
        Type types = new TypeToken<String>() {
        }.getType();
        Communicator<String> communicator = new Communicator<>(cxt, SEARCH_USER_PRIVILEGE);
        HashMap<String, String> params = new HashMap<>();
        params.put("type", type);
        return communicator.get(params, types);
    }

    /**
     * 查询用户某种权限
     * @param cxt
     * @param type  权限类型的编码
     */
    public static String searchUserPrivilege(Context cxt, String type) throws Exception {
        Type types = new TypeToken<String>() {
        }.getType();
        Communicator<String> communicator = new Communicator<>(cxt, SEARCH_USER_PRIVILEGE + "/" + type);
        return communicator.get(types);
    }
}
